package com.exam.action;

import java.util.Map;

import com.exam.bean.Paper;
import com.exam.bean.User;
import com.exam.service.PaperService;
import com.exam.service.impl.PaperServiceImpl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class PaperAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private Paper paper = new Paper(); 
	
	//添加试卷入口
	public String add(){
		PaperService service = new PaperServiceImpl();
		Map<String, Object> session = ActionContext.getContext().getSession();
		try {
			User user = (User) session.get("loginuser");
			if(user!=null){
				paper.setUser(user);
			}
			paper.setStatus(null);//默认是无效的 
			service.add(paper);
		} catch (Exception e) { 
			e.printStackTrace();
			return "exception";
		}
		return "listPapers";
	}

	public Paper getPaper() {
		return paper;
	}

	public void setPaper(Paper paper) {
		this.paper = paper;
	}

}
